<#include '/admin/header.html' >

<div id="memberpricedlg"></div>
<div class="main">
	<div class="input">
		<form method="post" name="theForm" id="theForm">
			<#if is_edit==true>
				<input value="${ctx}/shop/admin/goods/save-edit.do" type="hidden" id="goods_inputAction" />
			 	<input type="hidden" name="isedit" value="yes" />
				<input type="hidden" name="goods_id" value="${goodsView.goods_id  }" />
			<#else>
				<input value="${ctx}/shop/admin/goods/save-add.do" type="hidden" id="goods_inputAction" />
			</#if>
			<div style="display: block;" class="goods_input">
				<div class="contentTab">
					<ul class="tab">
						<#list pluginTabs as tab>
							<li tabid="${tab.order}" <#if tab.order==1> class="contentTabS"</#if> >
								${tab.tabTitle}
							</li> 
						</#list>
						
					</ul>
				</div>
				<div class="shadowBoxWhite wf100 whiteBox">
					<div class="text">
						<div class="tab-page">
							<#list pluginHtmls as tab>
								<li tabid="${tab.order}"
									<#if tab.order!=1> 
										style="display:none"
									</#if> 
									class="tab-panel"> 
									${tab.tabHtml}
								</li> 
							</#list>
						</div>
					</div>
				</div>
			</div>
		</form>
		<div class="buttonWrap">
			<a href="javascript:;" id="goodsinput" class="easyui-linkbutton">确定</a>
		</div>
	</div>
</div>
<script type="text/javascript">
	
	$(function() {

		$(".goods_input .contentTab>ul>li").click(function() {
			var tabid = $(this).attr("tabid");
			$(".goods_input .contentTab>ul>li").removeClass("contentTabS");
			$(this).addClass("contentTabS");
			$(".tab-page .tab-panel").hide();
			$(".tab-panel[tabid=" + tabid + "]").show();
		});

		$("input[type=text]").attr("autocomplete", "off");
		
		$("#goodsinput").click(function() {
			
			//判断linkbutton是否已禁用，如果禁用则跳过
		 	var disabled=  $(this).hasClass("l-btn-disabled");
			if( !disabled ){
				var formflag = $("#theForm").form('validate');
				if (formflag) {
					$("#goodsinput").linkbutton("disable");
					$.Loading.show("正在保存请稍后..");
					var options = {
						url : $("#goods_inputAction").val() ,
						type : "POST",
						dataType : "json",
						success : function(result) {
							
							if (result.result == 1) {
								$.Loading.success(result.message);
								if( $("#goods_inputAction").val()=="${ctx}/shop/admin/goods/save-add.do" ){
									parent.updateCurrentTab($("input[name='name']").val(),"${ctx}/shop/admin/goods/edit.do?goodsId="+result.data)
								}else{
									$("#goodsinput").linkbutton("enable");
								}
							}else{
								$.Loading.error(result.message);
								$("#goodsinput").linkbutton("enable");
							}
						},
						error : function(e) {
							$.Loading.error("出错了,请重试");
							$("#goodsinput").linkbutton("enable");
						}
					};
					$('#theForm').ajaxSubmit(options);
				}else{
					$(".goods_input .contentTab>ul>li").removeClass("contentTabS");
					$(this).addClass("contentTabS");
					$(".tab-page .tab-panel").hide();
					$(".tab-panel[tabid=" + tabid + "]").show();
					
					var tabid=$(".validatebox-invalid:first").parent().parent().parent().parent().parent().attr("tabid");
					if(tabid==null){
						var tabid=$(".validatebox-invalid:first").parent().parent().parent().parent().parent().parent().attr("tabid");
					}
					$(".tab-panel[tabid=" + tabid + "]").show();
				}
			}
		});
	});
</script>

<#include '/admin/footer.html' >
